<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/resources/modelo_facelets.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">    

    <ui:define name="content">     

            <p:panel id="paineladicionar" header="Cadastrar Serviços" >

                <p:messages/>
                
                <h:form id="formAdicionar">
                    
                    <h:panelGrid columns="2" cellspacing="20px" width="100%" >

                        <h:outputText value="Nome do Serviço: " />  

                        <p:inputText id="nomeServico" 
                                     value="#{servico.nome}" 
                                     required="true" 
                                     requiredMessage="O nome do servico é obrigatório!"
                                     label="Nome do Solicitante">  
                            <f:validateLength minimum="3" />  

                        </p:inputText>              

                    </h:panelGrid>

                    <p:commandButton value="Adicionar" 
                                     actionListener="#{servico.adicionarServico()}" 
                                     update=":paineladicionar :paineltabela"/>
                </h:form>

            </p:panel>

        <p:panel id="paineltabela" header="Solicitantes Cadastrados">
            
            <h:form id="formTabela">

                <p:dataTable id="tabela"                             
                             value="#{servico.tabela}"
                             var="itemServico"                                     
                             rows="10"  
                             pageLinks="5"
                             rowsPerPageTemplate="5,10,15"
                             selectionMode="single"
                             selection="#{servico.servicoSelecionado}"
                             paginator="true"       
                             emptyMessage="Nenhum registro encontrado."
                             paginatorPosition="bottom"                             
                             paginatorTemplate="{RowsPerPageDropdown} {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"                             
                             >

                    <p:column headerText="Nome do Solicitante" sortBy="#{itemServico.nome}" filterBy="#{itemServico.nome}">
                        <h:outputText value="#{itemServico.nome}"/>                              
                    </p:column>     

                    <f:facet name="footer">
                        <p:commandButton value="Excluir" action="#{servico.removerServico()}" update=":paineladicionar :paineltabela" />
                    </f:facet>

                </p:dataTable>

            </h:form>

        </p:panel>

    </ui:define>

</ui:composition>